package com.yxj04;

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;

public class OutputStreamWriteDemo {
    public static void main(String[] args) throws IOException {
        //字符流写数据的方法
        //void write(int c) 写入一个字符
        OutputStreamWriter osw = new OutputStreamWriter(new FileOutputStream("D:\\Ccode\\jdata-structure\\ByteStream9\\osw.txt"));
//        osw.write(97);
//        osw.flush();
//        osw.write(98);
//        osw.flush();

        //void write(char[] cbuf) 写入一个字符数组
//        char[] chs = {'a','b','c'};
//        osw.write(chs);

        //写字符数组的一部分 void write(char[] cbuf, int off, int len)
        //char[] chs = {'a','b','c','d'};
//        osw.write(chs,0,chs.length);
        //osw.write(chs,1,3);

        //写一个字符串 void write(String str)
//        osw.write("wwww");
        //void write(String str, int off, int len) 写字符串的一部分
        osw.write("sffs",1,3);

        //先刷新，再关闭
        osw.close();
    }
}
